package com.market.plus.controller.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.market.plus.core.util.MarketUtil;

public class GuestViewInterceptor extends HandlerInterceptorAdapter {

   private String urlRedirect;

   @Override
   public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
      if (MarketUtil.hasGuestView()){
         String url = request.getContextPath() + urlRedirect;
         response.sendRedirect(url);
         return false;
      }
      return true;
   }

   public String getUrlRedirect() {
      return urlRedirect;
   }

   public void setUrlRedirect(String urlRedirect) {
      this.urlRedirect = urlRedirect;
   }
}
